home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / apa.bst (.txt) < prev    next >
LaTeX Document  |  1992-07-19  |  24KB  |  904 lines

  1. %%% ====================================================================
  2. %%%  @BibTeX-style-file{
  3. %%%     author          = "Alan Rogers",
  4. %%%     version         = "1.1",
  5. %%%     date            = "June 27, 1992",
  6. %%%     filename        = "apa.bst",
  7. %%%     address         = "Dept of Anthropology, University of Utah,
  8. %%%                       Salt Lake City, UT 84112",
  9. %%%     checksum        = "21129 1130 3156 23582",
  10. %%%     email           = "rogers@anthro.utah.edu",
  11. %%%     supported       = "no",
  12. %%%     docstring       = "Adapted from apalike.bst.
  13. %%%                        Usage: \documentstyle[astron]{...}
  14. %%%                          ...
  15. %%%                          \bibliographystyle{apa}
  16. %%%                          ...
  17. %%%                        This file incorporates features of Sake J.
  18. %%%                        Hogeveen's `astron.bst' into`apalike.bst'.
  19. %%%                        The \documentstyle command above invokes
  20. %%%                        Hogeveen's `astron.sty', which must be in
  21. %%%                        TeX's search path.
  22. %%%                        The modifications implement `\cite*{}', which
  23. %%%                        generates references in short form.  For
  24. %%%                        example, `Rogers \cite*{...}' would produce
  25. %%%                        `Rogers (1992)'."
  26. %%%  }
  27. %%% ====================================================================
  28. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29. % BibTeX `apalike' bibliography style (24-Jan-88 version)
  30. % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
  31. % Copyright (C) 1988, all rights reserved.
  32. % Copying of this file is allowed, provided that if you make any changes at all
  33. % you name it something other than `apalike.bst'.
  34. % This restriction helps ensure that all copies are identical.
  35. % Differences between this style and `alpha' are generally heralded by a `%'.
  36. % The file btxbst.doc has the documentation for alpha.bst.
  37. % This style should be used with the `apalike' LaTeX style (apalike.sty).
  38. % \cite's come out like "(Jones, 1986)" in the text but there are no labels
  39. % in the bibliography, and something like "(1986)" comes out immediately
  40. % after the author.  Author (and editor) names appear as last name, comma,
  41. % initials.  A `year' field is required for every entry, and so is either
  42. % an author (or in some cases, an editor) field or a key field.
  43. % Editorial note:
  44. % Many journals require a style like `apalike', but I strongly, strongly,
  45. % strongly recommend that you not use it if you have a choice---use something
  46. % like `plain' instead.  Mary-Claire van Leunen (A Handbook for Scholars,
  47. % Knopf, 1979) argues convincingly that a style like `plain' encourages better
  48. % writing than one like `apalike'.  Furthermore the strongest arguments for
  49. % using an author-date style like `apalike'---that it's "the most practical"
  50. % (The Chicago Manual of Style, University of Chicago Press, thirteenth
  51. % edition, 1982, pages 400--401)---fall flat on their face with the new
  52. % computer-typesetting technology.  For instance page 401 anachronistically
  53. % states "The chief disadvantage of [a style like `plain'] is that additions
  54. % or deletions cannot be made after the manuscript is typed without changing
  55. % numbers in both text references and list."  LaTeX sidesteps the disadvantage.
  56. % History:
  57. %   15-sep-86    (SK,OP)    Original version, by Susan King and Oren Patashnik.
  58. %   10-nov-86    (OP)    Truncated the sort.key$ string to the correct length
  59. %            in bib.sort.order to eliminate error message.
  60. %   24-jan-88    (OP)    Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
  61. %            apalike now sorts by author, then year, then title;
  62. %            THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
  63. ENTRY
  64.   { address
  65.     author
  66.     booktitle
  67.     chapter
  68.     edition
  69.     editor
  70.     howpublished
  71.     institution
  72.     journal
  73.     key
  74. %    month        not used in apalike
  75.     note
  76.     number
  77.     organization
  78.     pages
  79.     publisher
  80.     school
  81.     series
  82.     title
  83.     type
  84.     volume
  85.     year
  86.   { label extra.label sort.label }
  87. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  88. FUNCTION {init.state.consts}
  89. { #0 'before.all :=
  90.   #1 'mid.sentence :=
  91.   #2 'after.sentence :=
  92.   #3 'after.block :=
  93. STRINGS { s t }
  94. FUNCTION {output.nonnull}
  95. { 's :=
  96.   output.state mid.sentence =
  97.     { ", " * write$ }
  98.     { output.state after.block =
  99.     { add.period$ write$
  100.       newline$
  101.       "\newblock " write$
  102.     { output.state before.all =
  103.         'write$
  104.         { add.period$ " " * write$ }
  105.       if$
  106.       if$
  107.       mid.sentence 'output.state :=
  108.     }
  109.   if$
  110. FUNCTION {output}
  111. { duplicate$ empty$
  112.     'pop$
  113.     'output.nonnull
  114.   if$
  115. FUNCTION {output.check}
  116. { 't :=
  117.   duplicate$ empty$
  118.     { pop$ "empty " t * " in " * cite$ * warning$ }
  119.     'output.nonnull
  120.   if$
  121. %                    apalike needs this function because
  122. %                    the year has special punctuation;
  123. %                    apalike ignores the month
  124. FUNCTION {output.year.check}
  125. { year empty$
  126.     { "empty year in " cite$ * warning$ }
  127.     { write$
  128.       " (" year * extra.label * ")" *
  129.       mid.sentence 'output.state :=
  130.     }
  131.   if$
  132. FUNCTION {output.bibitem}
  133. { newline$
  134.   "\bibitem[" write$
  135.   label write$
  136.   "]{" write$
  137.   cite$ write$
  138.   "}" write$
  139.   newline$
  140.   before.all 'output.state :=
  141. FUNCTION {fin.entry}
  142. { add.period$
  143.   write$
  144.   newline$
  145. FUNCTION {new.block}
  146. { output.state before.all =
  147.     'skip$
  148.     { after.block 'output.state := }
  149.   if$
  150. FUNCTION {new.sentence}
  151. { output.state after.block =
  152.     'skip$
  153.     { output.state before.all =
  154.     'skip$
  155.     { after.sentence 'output.state := }
  156.       if$
  157.     }
  158.   if$
  159. FUNCTION {not}
  160. {   { #0 }
  161.     { #1 }
  162.   if$
  163. FUNCTION {and}
  164. {   'skip$
  165.     { pop$ #0 }
  166.   if$
  167. FUNCTION {or}
  168. {   { pop$ #1 }
  169.     'skip$
  170.   if$
  171. FUNCTION {new.block.checkb}
  172. { empty$
  173.   swap$ empty$
  174.   and
  175.     'skip$
  176.     'new.block
  177.   if$
  178. FUNCTION {field.or.null}
  179. { duplicate$ empty$
  180.     { pop$ "" }
  181.     'skip$
  182.   if$
  183. FUNCTION {emphasize}
  184. { duplicate$ empty$
  185.     { pop$ "" }
  186.     { "{\em " swap$ * "}" * }
  187.   if$
  188. INTEGERS { nameptr namesleft numnames }
  189. FUNCTION {format.names}
  190. { 's :=
  191.   #1 'nameptr :=
  192.   s num.names$ 'numnames :=
  193.   numnames 'namesleft :=
  194.     { namesleft #0 > }
  195.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  196.       nameptr #1 >
  197.     { namesleft #1 >
  198.         { ", " * t * }
  199.         { numnames #2 >
  200.         { "," * }
  201.         'skip$
  202.           if$
  203.           t "others" =
  204.         { " et~al." * }
  205.         { " and " * t * }
  206.           if$
  207.         }
  208.       if$
  209.       if$
  210.       nameptr #1 + 'nameptr :=
  211.       namesleft #1 - 'namesleft :=
  212.     }
  213.   while$
  214. FUNCTION {format.authors}
  215. { author empty$
  216.     { "" }
  217.     { author format.names }
  218.   if$
  219. FUNCTION {format.key}            % this function is just for apalike
  220. { empty$
  221.     { key field.or.null }
  222.     { "" }
  223.   if$
  224. FUNCTION {format.editors}
  225. { editor empty$
  226.     { "" }
  227.     { editor format.names
  228.       editor num.names$ #1 >
  229.     { ", editors" * }
  230.     { ", editor" * }
  231.       if$
  232.     }
  233.   if$
  234. FUNCTION {format.title}
  235. { title empty$
  236.     { "" }
  237.     { title "t" change.case$ }
  238.   if$
  239. FUNCTION {n.dashify}
  240. { 't :=
  241.     { t empty$ not }
  242.     { t #1 #1 substring$ "-" =
  243.     { t #1 #2 substring$ "--" = not
  244.         { "--" *
  245.           t #2 global.max$ substring$ 't :=
  246.         }
  247.         {   { t #1 #1 substring$ "-" = }
  248.         { "-" *
  249.           t #2 global.max$ substring$ 't :=
  250.           while$
  251.         }
  252.       if$
  253.     { t #1 #1 substring$ *
  254.       t #2 global.max$ substring$ 't :=
  255.       if$
  256.     }
  257.   while$
  258. FUNCTION {format.btitle}
  259. { title emphasize
  260. FUNCTION {tie.or.space.connect}
  261. { duplicate$ text.length$ #3 <
  262.     { "~" }
  263.     { " " }
  264.   if$
  265.   swap$ * *
  266. FUNCTION {either.or.check}
  267. { empty$
  268.     'pop$
  269.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  270.   if$
  271. FUNCTION {format.bvolume}
  272. { volume empty$
  273.     { "" }
  274.     { "volume" volume tie.or.space.connect
  275.       series empty$
  276.     'skip$
  277.     { " of " * series emphasize * }
  278.       if$
  279.       "volume and number" number either.or.check
  280.     }
  281.   if$
  282. FUNCTION {format.number.series}
  283. { volume empty$
  284.     { number empty$
  285.     { series field.or.null }
  286.     { output.state mid.sentence =
  287.         { "number" }
  288.         { "Number" }
  289.       if$
  290.       number tie.or.space.connect
  291.       series empty$
  292.         { "there's a number but no series in " cite$ * warning$ }
  293.         { " in " * series * }
  294.       if$
  295.       if$
  296.     }
  297.     { "" }
  298.   if$
  299. FUNCTION {format.edition}
  300. { edition empty$
  301.     { "" }
  302.     { output.state mid.sentence =
  303.     { edition "l" change.case$ " edition" * }
  304.     { edition "t" change.case$ " edition" * }
  305.       if$
  306.     }
  307.   if$
  308. INTEGERS { multiresult }
  309. FUNCTION {multi.page.check}
  310. { 't :=
  311.   #0 'multiresult :=
  312.     { multiresult not
  313.       t empty$ not
  314.       and
  315.     }
  316.     { t #1 #1 substring$
  317.       duplicate$ "-" =
  318.       swap$ duplicate$ "," =
  319.       swap$ "+" =
  320.       or or
  321.     { #1 'multiresult := }
  322.     { t #2 global.max$ substring$ 't := }
  323.       if$
  324.     }
  325.   while$
  326.   multiresult
  327. FUNCTION {format.pages}
  328. { pages empty$
  329.     { "" }
  330.     { pages multi.page.check
  331.     { "pages" pages n.dashify tie.or.space.connect }
  332.     { "page" pages tie.or.space.connect }
  333.       if$
  334.     }
  335.   if$
  336. FUNCTION {format.vol.num.pages}
  337. { volume field.or.null
  338.   number empty$
  339.     'skip$
  340.     { "(" number * ")" * *
  341.       volume empty$
  342.     { "there's a number but no volume in " cite$ * warning$ }
  343.     'skip$
  344.       if$
  345.     }
  346.   if$
  347.   pages empty$
  348.     'skip$
  349.     { duplicate$ empty$
  350.     { pop$ format.pages }
  351.     { ":" * pages n.dashify * }
  352.       if$
  353.     }
  354.   if$
  355. FUNCTION {format.chapter.pages}
  356. { chapter empty$
  357.     'format.pages
  358.     { type empty$
  359.     { "chapter" }
  360.     { type "l" change.case$ }
  361.       if$
  362.       chapter tie.or.space.connect
  363.       pages empty$
  364.     'skip$
  365.     { ", " * format.pages * }
  366.       if$
  367.     }
  368.   if$
  369. FUNCTION {format.in.ed.booktitle}
  370. { booktitle empty$
  371.     { "" }
  372.     { editor empty$
  373.     { "In " booktitle emphasize * }
  374.     { "In " format.editors * ", " * booktitle emphasize * }
  375.       if$
  376.     }
  377.   if$
  378. FUNCTION {format.thesis.type}
  379. { type empty$
  380.     'skip$
  381.     { pop$
  382.       type "t" change.case$
  383.     }
  384.   if$
  385. FUNCTION {format.tr.number}
  386. { type empty$
  387.     { "Technical Report" }
  388.     'type
  389.   if$
  390.   number empty$
  391.     { "t" change.case$ }
  392.     { number tie.or.space.connect }
  393.   if$
  394. FUNCTION {format.article.crossref}
  395. { "In"                            % this is for apalike
  396.   " \cite{" * crossref * "}" *
  397. FUNCTION {format.book.crossref}
  398. { volume empty$
  399.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  400.       "In "
  401.     }
  402.     { "Volume" volume tie.or.space.connect
  403.       " of " *
  404.     }
  405.   if$
  406.   "\cite{" * crossref * "}" *                % this is for apalike
  407. FUNCTION {format.incoll.inproc.crossref}
  408. { "In"                            % this is for apalike
  409.   " \cite{" * crossref * "}" *
  410. FUNCTION {article}
  411. { output.bibitem
  412.   format.authors "author" output.check
  413.   author format.key output                % special for
  414.   output.year.check                    % apalike
  415.   new.block
  416.   format.title "title" output.check
  417.   new.block
  418.   crossref missing$
  419.     { journal emphasize "journal" output.check
  420.       format.vol.num.pages output
  421.     }
  422.     { format.article.crossref output.nonnull
  423.       format.pages output
  424.     }
  425.   if$
  426.   new.block
  427.   note output
  428.   fin.entry
  429. FUNCTION {book}
  430. { output.bibitem
  431.   author empty$
  432.     { format.editors "author and editor" output.check
  433.       editor format.key output
  434.     }
  435.     { format.authors output.nonnull
  436.       crossref missing$
  437.     { "author and editor" editor either.or.check }
  438.     'skip$
  439.       if$
  440.     }
  441.   if$
  442.   output.year.check                % special for apalike
  443.   new.block
  444.   format.btitle "title" output.check
  445.   crossref missing$
  446.     { format.bvolume output
  447.       new.block
  448.       format.number.series output
  449.       new.sentence
  450.       publisher "publisher" output.check
  451.       address output
  452.     }
  453.     { new.block
  454.       format.book.crossref output.nonnull
  455.     }
  456.   if$
  457.   format.edition output
  458.   new.block
  459.   note output
  460.   fin.entry
  461. FUNCTION {booklet}
  462. { output.bibitem
  463.   format.authors output
  464.   author format.key output                % special for
  465.   output.year.check                    % apalike
  466.   new.block
  467.   format.title "title" output.check
  468.   new.block
  469.   howpublished output
  470.   address output
  471.   new.block
  472.   note output
  473.   fin.entry
  474. FUNCTION {inbook}
  475. { output.bibitem
  476.   author empty$
  477.     { format.editors "author and editor" output.check
  478.       editor format.key output
  479.     }
  480.     { format.authors output.nonnull
  481.       crossref missing$
  482.     { "author and editor" editor either.or.check }
  483.     'skip$
  484.       if$
  485.     }
  486.   if$
  487.   output.year.check                % special for apalike
  488.   new.block
  489.   format.btitle "title" output.check
  490.   crossref missing$
  491.     { format.bvolume output
  492.       format.chapter.pages "chapter and pages" output.check
  493.       new.block
  494.       format.number.series output
  495.       new.sentence
  496.       publisher "publisher" output.check
  497.       address output
  498.     }
  499.     { format.chapter.pages "chapter and pages" output.check
  500.       new.block
  501.       format.book.crossref output.nonnull
  502.     }
  503.   if$
  504.   format.edition output
  505.   new.block
  506.   note output
  507.   fin.entry
  508. FUNCTION {incollection}
  509. { output.bibitem
  510.   format.authors "author" output.check
  511.   author format.key output                % special for
  512.   output.year.check                    % apalike
  513.   new.block
  514.   format.title "title" output.check
  515.   new.block
  516.   crossref missing$
  517.     { format.in.ed.booktitle "booktitle" output.check
  518.       format.bvolume output
  519.       format.number.series output
  520.       format.chapter.pages output
  521.       new.sentence
  522.       publisher "publisher" output.check
  523.       address output
  524.       format.edition output
  525.     }
  526.     { format.incoll.inproc.crossref output.nonnull
  527.       format.chapter.pages output
  528.     }
  529.   if$
  530.   new.block
  531.   note output
  532.   fin.entry
  533. FUNCTION {inproceedings}
  534. { output.bibitem
  535.   format.authors "author" output.check
  536.   author format.key output                % special for
  537.   output.year.check                    % apalike
  538.   new.block
  539.   format.title "title" output.check
  540.   new.block
  541.   crossref missing$
  542.     { format.in.ed.booktitle "booktitle" output.check
  543.       format.bvolume output
  544.       format.number.series output
  545.       format.pages output
  546.       address output                    % for apalike
  547.       new.sentence                    % there's no year
  548.       organization output                % here so things
  549.       publisher output                    % are simpler
  550.     }
  551.     { format.incoll.inproc.crossref output.nonnull
  552.       format.pages output
  553.     }
  554.   if$
  555.   new.block
  556.   note output
  557.   fin.entry
  558. FUNCTION {conference} { inproceedings }
  559. FUNCTION {manual}
  560. { output.bibitem
  561.   format.authors output
  562.   author format.key output                % special for
  563.   output.year.check                    % apalike
  564.   new.block
  565.   format.btitle "title" output.check
  566.   organization address new.block.checkb
  567.   organization output
  568.   address output
  569.   format.edition output
  570.   new.block
  571.   note output
  572.   fin.entry
  573. FUNCTION {mastersthesis}
  574. { output.bibitem
  575.   format.authors "author" output.check
  576.   author format.key output                % special for
  577.   output.year.check                    % apalike
  578.   new.block
  579.   format.title "title" output.check
  580.   new.block
  581.   "Master's thesis" format.thesis.type output.nonnull
  582.   school "school" output.check
  583.   address output
  584.   new.block
  585.   note output
  586.   fin.entry
  587. FUNCTION {misc}
  588. { output.bibitem
  589.   format.authors output
  590.   author format.key output                % special for
  591.   output.year.check                    % apalike
  592.   new.block
  593.   format.title output
  594.   new.block
  595.   howpublished output
  596.   new.block
  597.   note output
  598.   fin.entry
  599. FUNCTION {phdthesis}
  600. { output.bibitem
  601.   format.authors "author" output.check
  602.   author format.key output                % special for
  603.   output.year.check                    % apalike
  604.   new.block
  605.   format.btitle "title" output.check
  606.   new.block
  607.   "PhD thesis" format.thesis.type output.nonnull
  608.   school "school" output.check
  609.   address output
  610.   new.block
  611.   note output
  612.   fin.entry
  613. FUNCTION {proceedings}
  614. { output.bibitem
  615.   format.editors output
  616.   editor format.key output                % special for
  617.   output.year.check                    % apalike
  618.   new.block
  619.   format.btitle "title" output.check
  620.   format.bvolume output
  621.   format.number.series output
  622.   address output                % for apalike
  623.   new.sentence                    % we always output
  624.   organization output                % a nonempty organization
  625.   publisher output                % here
  626.   new.block
  627.   note output
  628.   fin.entry
  629. FUNCTION {techreport}
  630. { output.bibitem
  631.   format.authors "author" output.check
  632.   author format.key output                % special for
  633.   output.year.check                    % apalike
  634.   new.block
  635.   format.title "title" output.check
  636.   new.block
  637.   format.tr.number output.nonnull
  638.   institution "institution" output.check
  639.   address output
  640.   new.block
  641.   note output
  642.   fin.entry
  643. FUNCTION {unpublished}
  644. { output.bibitem
  645.   format.authors "author" output.check
  646.   author format.key output                % special for
  647.   output.year.check                    % apalike
  648.   new.block
  649.   format.title "title" output.check
  650.   new.block
  651.   note "note" output.check
  652.   fin.entry
  653. FUNCTION {default.type} { misc }
  654. MACRO {jan} {"January"}
  655. MACRO {feb} {"February"}
  656. MACRO {mar} {"March"}
  657. MACRO {apr} {"April"}
  658. MACRO {may} {"May"}
  659. MACRO {jun} {"June"}
  660. MACRO {jul} {"July"}
  661. MACRO {aug} {"August"}
  662. MACRO {sep} {"September"}
  663. MACRO {oct} {"October"}
  664. MACRO {nov} {"November"}
  665. MACRO {dec} {"December"}
  666. MACRO {acmcs} {"ACM Computing Surveys"}
  667. MACRO {acta} {"Acta Informatica"}
  668. MACRO {cacm} {"Communications of the ACM"}
  669. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  670. MACRO {ibmsj} {"IBM Systems Journal"}
  671. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  672. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  673. MACRO {ieeetcad}
  674.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  675. MACRO {ipl} {"Information Processing Letters"}
  676. MACRO {jacm} {"Journal of the ACM"}
  677. MACRO {jcss} {"Journal of Computer and System Sciences"}
  678. MACRO {scp} {"Science of Computer Programming"}
  679. MACRO {sicomp} {"SIAM Journal on Computing"}
  680. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  681. MACRO {tods} {"ACM Transactions on Database Systems"}
  682. MACRO {tog} {"ACM Transactions on Graphics"}
  683. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  684. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  685. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  686. MACRO {tcs} {"Theoretical Computer Science"}
  687. FUNCTION {sortify}
  688. { purify$
  689.   "l" change.case$
  690. INTEGERS { len }
  691. FUNCTION {chop.word}
  692. { 's :=
  693.   'len :=
  694.   s #1 len substring$ =
  695.     { s len #1 + global.max$ substring$ }
  696.     's
  697.   if$
  698. %            There are three apalike cases: one person (Jones),
  699. %            two (Jones and de~Bruijn), and more (Jones et~al.).
  700. %            This function is much like format.crossref.editors.
  701. FUNCTION {format.lab.names}
  702. { 's :=
  703.   s #1 "{vv~}{ll}" format.name$
  704.   s num.names$ duplicate$
  705.   #2 >
  706.     { pop$ " et~al." * }
  707.     { #2 <
  708.     'skip$
  709.     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  710.         { " et~al." * }
  711.         { " and " * s #2 "{vv~}{ll}" format.name$ * }
  712.       if$
  713.       if$
  714.     }
  715.   if$
  716. FUNCTION {author.key.label}
  717. { author empty$
  718.     { key empty$
  719.     { cite$ #1 #3 substring$ }
  720.     'key                    % apalike uses the whole key
  721.       if$
  722.     }
  723.     { author format.lab.names }
  724.   if$
  725. FUNCTION {author.editor.key.label}
  726. { author empty$
  727.     { editor empty$
  728.     { key empty$
  729.         { cite$ #1 #3 substring$ }
  730.         'key                % apalike uses the whole key
  731.       if$
  732.     { editor format.lab.names }
  733.       if$
  734.     }
  735.     { author format.lab.names }
  736.   if$
  737. FUNCTION {editor.key.label}
  738. { editor empty$
  739.     { key empty$
  740.     { cite$ #1 #3 substring$ }
  741.     'key            % apalike uses the whole key, no organization
  742.       if$
  743.     }
  744.     { editor format.lab.names }
  745.   if$
  746. FUNCTION {calc.label}      % this function came from ASTRON.BST (ARR)
  747. { type$ "book" =
  748.   type$ "inbook" =
  749.     'author.editor.key.label
  750.     { type$ "proceedings" =
  751.         'editor.key.label                       % apalike ignores organization
  752.         'author.key.label                       % for labeling and sorting
  753.       if$
  754.     }
  755.   if$
  756.   "\protect\astroncite{" swap$ * "}{"                   % these three lines are
  757.   *                                                     % for apalike, which
  758.   year field.or.null purify$ #-1 #4 substring$          % uses all four digits
  759.   *                       % the mathing closing "}" comes in at the reverse.pass
  760.   'label :=
  761. FUNCTION {sort.format.names}
  762. { 's :=
  763.   #1 'nameptr :=
  764.   s num.names$ 'numnames :=
  765.   numnames 'namesleft :=
  766.     { namesleft #0 > }
  767.     { nameptr #1 >
  768.     { "   " * }
  769.     'skip$
  770.       if$                        % apalike uses initials
  771.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't := % <= here
  772.       nameptr numnames = t "others" = and
  773.     { "et al" * }
  774.     { t sortify * }
  775.       if$
  776.       nameptr #1 + 'nameptr :=
  777.       namesleft #1 - 'namesleft :=
  778.     }
  779.   while$
  780. FUNCTION {sort.format.title}
  781. { 't :=
  782.   "A " #2
  783.     "An " #3
  784.       "The " #4 t chop.word
  785.     chop.word
  786.   chop.word
  787.   sortify
  788.   #1 global.max$ substring$
  789. FUNCTION {author.sort}
  790. { author empty$
  791.     { key empty$
  792.     { "to sort, need author or key in " cite$ * warning$
  793.       ""
  794.     { key sortify }
  795.       if$
  796.     }
  797.     { author sort.format.names }
  798.   if$
  799. FUNCTION {author.editor.sort}
  800. { author empty$
  801.     { editor empty$
  802.     { key empty$
  803.         { "to sort, need author, editor, or key in " cite$ * warning$
  804.           ""
  805.         }
  806.         { key sortify }
  807.       if$
  808.     { editor sort.format.names }
  809.       if$
  810.     }
  811.     { author sort.format.names }
  812.   if$
  813. FUNCTION {editor.sort}
  814. { editor empty$
  815.     { key empty$
  816.     { "to sort, need editor or key in " cite$ * warning$
  817.       ""
  818.     { key sortify }
  819.       if$
  820.     }
  821.     { editor sort.format.names }
  822.   if$
  823. %            apalike uses two sorting passes; the first one sets the
  824. %            labels so that the `a's, `b's, etc. can be computed;
  825. %            the second pass puts the references in "correct" order.
  826. %            The presort function is for the first pass. It computes
  827. %            label, sort.label, and title, and then concatenates.
  828. FUNCTION {presort}
  829. { calc.label
  830.   label sortify
  831.   "    "
  832.   type$ "book" =
  833.   type$ "inbook" =
  834.     'author.editor.sort
  835.     { type$ "proceedings" =
  836.     'editor.sort
  837.     'author.sort
  838.       if$
  839.     }
  840.   if$
  841.   #1 entry.max$ substring$    % for
  842.   'sort.label :=        % apalike
  843.   sort.label            % style
  844.   "    "
  845.   title field.or.null
  846.   sort.format.title
  847.   #1 entry.max$ substring$
  848.   'sort.key$ :=
  849. ITERATE {presort}
  850. SORT        % by label, sort.label, title---for final label calculation
  851. STRINGS { last.label next.extra }    % apalike labels are only for the text;
  852. INTEGERS { last.extra.num }        % there are none in the bibliography
  853. FUNCTION {initialize.extra.label.stuff}    % and hence there is no `longest.label'
  854. { #0 int.to.chr$ 'last.label :=
  855.   "" 'next.extra :=
  856.   #0 'last.extra.num :=
  857. FUNCTION {forward.pass}
  858. { last.label label =
  859.     { last.extra.num #1 + 'last.extra.num :=
  860.       last.extra.num int.to.chr$ 'extra.label :=
  861.     }
  862.     { "a" chr.to.int$ 'last.extra.num :=
  863.       "" 'extra.label :=
  864.       label 'last.label :=
  865.     }
  866.   if$
  867. FUNCTION {reverse.pass}       % this function came from ASTRON.BST (ARR)
  868. { next.extra "b" =
  869.     { "a" 'extra.label := }
  870.     'skip$
  871.   if$
  872.   label extra.label * "}" * 'label :=
  873.   extra.label 'next.extra :=
  874. EXECUTE {initialize.extra.label.stuff}
  875. ITERATE {forward.pass}
  876. REVERSE {reverse.pass}
  877. %                Now that the label is right we sort for real,
  878. %                on sort.label then year then title.  This is
  879. %                for the second sorting pass.
  880. FUNCTION {bib.sort.order}
  881. { sort.label
  882.   "    "
  883.   year field.or.null sortify
  884.   "    "
  885.   title field.or.null
  886.   sort.format.title
  887.   #1 entry.max$ substring$
  888.   'sort.key$ :=
  889. ITERATE {bib.sort.order}
  890. SORT        % by sort.label, year, title---giving final bibliography order
  891. FUNCTION {begin.bib}
  892. { preamble$ empty$                % no \etalchar in apalike
  893.     'skip$
  894.     { preamble$ write$ newline$ }
  895.   if$
  896.   "\begin{thebibliography}{}" write$ newline$        % no labels in apalike
  897. EXECUTE {begin.bib}
  898. EXECUTE {init.state.consts}
  899. ITERATE {call.type$}
  900. FUNCTION {end.bib}
  901. { newline$
  902.   "\end{thebibliography}" write$ newline$
  903. EXECUTE {end.bib}
  904.